package com.itzhoun.service;

import com.baomidou.mybatisplus.extension.service.additional.update.impl.LambdaUpdateChainWrapper;
import com.itzhoun.entity.User;
import com.itzhoun.mapper.UserMapperMaster;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 周楠
 * @Date 2022/06/28/下午 9:48
 */
@Service
public class UserMasterServiceImpl implements UserMasterService {

    @Resource
    private UserMapperMaster userMasterMapper;

    @Override
    public User getUserById(Integer id) {
        return userMasterMapper.selectById(id);
    }

    @Override
    public int updateUser(User user) {
        boolean update = new LambdaUpdateChainWrapper<User>(this.userMasterMapper)
                .eq(User::getId, 1)
                .update(user);
        //测试事务
       // int a = 1 / 0;
        return update ? 1 :0 ;
    }
}
